package com.lening.community.controller;

import com.lening.common.base.BaseController;
import com.lening.common.web.Result;
import com.lening.community.dto.BuildingDto;
import com.lening.community.pojo.Building;
import com.lening.community.service.BuildingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.function.client.WebClient;

import java.util.List;

/**
 * @ToDo:
 * @Author：潘万法
 * @date: 2024/6/3 17:07
 */
@RestController
@RequestMapping("floor")
public class BuildingController extends BaseController<Building, BuildingDto, BuildingService> {
    @Autowired(required = false)
    private BuildingService buildingService;
    @Autowired(required = false)
    private WebClient webClient;

   /* @GetMapping("pages")
    public Page<Building> getByBuilding(BuildingDto buildingDto) {
        Page<Building> page = buildingService.getBuilding(buildingDto);

        return page;
    }*/

//    @Override
//    @GetMapping("/pages")
//    public Page<?> page(BuildingVo buildingVo) {
//        return buildingService.getBuilding(buildingVo);
//    }

    @GetMapping("getByCommunityId/{communityId}")
    public Result<?> getByCommunityId(@PathVariable("communityId") Long communityId) {
        List<Building> cList = buildingService.getCommunityId(communityId);
        return Result.ok(cList);
    }

    @GetMapping("getByBuildUid/{BuildUid}")
    public Result<?> getByBuildUid(@PathVariable("BuildUid") Long BuildUid) {
        List<Building> bList = buildingService.getBuildUid(BuildUid);
        return Result.ok(bList);
    }

    /**
     * 查询楼宇数量
     */
    @GetMapping("getCount")
    public int getCount() {
       return buildingService.getCount();
    }
}
